home *** CD-ROM | disk | FTP | other *** search
- /*
- pronet-start.c
-
- ProNET Quickstart. Prior to V3, you had to create MountLists and other
- config files to get ProNET started. Now it's much more easy!!
-
- */
-
- #include <string.h>
-
- #include <exec/execbase.h>
- #include <dos/dos.h>
- #include <dos/filehandler.h>
-
- #include <proto/exec.h>
- #include <proto/dos.h>
-
- void __chkabort(void) {} /* Disable CTRL-C handling */
- ULONG __nocommandline = 0;
-
- char template[]="LOCALNAME/A,REMOTENAME/A,UNIT/N,UNIQUE/S";
- LONG array[4];
- char handlername[]="l:pronet-handler";
-
- char versiontag[] = "$VER: pronet-start 37.0 (30.11.96)";
-
- struct RDArgs* rdargs;
- struct DosEnvec* environment;
- struct FileSysStartupMsg* fssm;
- UBYTE *strbuf;
- struct DeviceNode* dosentry;
- char faultbuf[60];
-
- char newarray0[20];
-
- int main()
- {
- ULONG result,i;
- char k;
-
- if(rdargs = ReadArgs(template,&array[0],NULL))
- {
- if(array[2]) array[2]=*((ULONG*)array[2]);
-
- if(fssm = AllocVec(sizeof(struct FileSysStartupMsg),MEMF_PUBLIC|MEMF_CLEAR))
- {
- if(environment = AllocVec(sizeof(struct DosEnvec),MEMF_PUBLIC|MEMF_CLEAR))
- {
- if(strbuf = AllocVec(128,MEMF_PUBLIC|MEMF_CLEAR))
- {
- environment->de_TableSize = 19;
- environment->de_Surfaces = 1;
- environment->de_SectorPerBlock = 1;
- environment->de_BlocksPerTrack = 1;
- environment->de_DosType = ID_DOS_DISK;
- if(array[3]) environment->de_HighCyl = 1;
-
- fssm->fssm_Unit = array[2];
- fssm->fssm_Environ = MKBADDR(environment);
- /* We want a BCPL string! */
- strcpy(strbuf+1,(const char*)array[1]);
- strbuf[0] = strlen((char*)array[1]);
- fssm->fssm_Device = MKBADDR(strbuf);
-
- /* Convert local name to uppercase */
- for(i=0 ; i<18 && ((char*)array[0])[i]!='\0' ; i++)
- {
- k=((char*)array[0])[i];
- newarray0[i] = (k>='a'&&k<='z' ? k-32 : k);
- }
- newarray0[i]='\0';
-
- if(dosentry = (struct DeviceNode*)MakeDosEntry(newarray0,DLT_DEVICE))
- {
- strcpy(strbuf+65,(const char*)handlername);
- strbuf[64] = strlen(handlername);
- dosentry->dn_Handler = MKBADDR(strbuf+64);
- dosentry->dn_StackSize = 4096;
- dosentry->dn_Priority = 10;
- dosentry->dn_Startup = MKBADDR(fssm);
- dosentry->dn_GlobalVec = -1;
-
- /* Add our device to the dos list */
- if(AddDosEntry((struct DosList*)dosentry))
- {
- /* ... and start it up! */
- strcat(newarray0,":");
- if(DeviceProc(newarray0))
- {
- /* Printf("Installed local `%s:', linked to `%s:' on unit %ld.\n",array[0],array[1],array[2]); */
- FreeArgs(rdargs);
- return(0);
- }
- else
- {
- switch(result=IoErr())
- {
- case 1000003:
- Printf("Device `%s:' on unit %ld doesn't exist.\n",array[1],array[2]);
- break;
-
- case 1000002:
- Printf("Couldn't open pronet.device.\n");
- break;
-
- case 1000001:
- Printf("Driver trouble: %s\n",(ULONG)strbuf);
- break;
-
- case 1000000:
- Printf("Unit %ld not defined.\n",array[2]);
- break;
-
- default:
- Fault(result,NULL,faultbuf,60);
- Printf("%s\n",(ULONG)faultbuf);
- }
-
- LockDosList(LDF_DEVICES|LDF_WRITE);
- RemDosEntry((struct DosList*)dosentry);
- UnLockDosList(LDF_DEVICES|LDF_WRITE);
- SetIoErr(0);
- }
- }
-
- FreeDosEntry((struct DosList*)dosentry);
- }
- FreeVec(strbuf);
- }
- FreeVec(environment);
- }
- FreeVec(fssm);
- }
- FreeArgs(rdargs);
- }
-
- PrintFault(IoErr(),NULL);
- return(20);
- }
-